﻿Imports System.Windows
Imports System.Windows.Controls


Namespace LightSwitchApplication
    Public Class SelectFileWindow
        Inherits ChildWindow

        Public Sub New()
            MyBase.New()
            InitializeComponent()
        End Sub

        Private _documentStream As FileStream

        Public Property DocumentStream As FileStream
            Get
                Return _documentStream
            End Get
            Set(value As FileStream)
                _documentStream = value
            End Set
        End Property

        Private _safeFileName As String =String.Empty 

        Public Property SafeFileName As String
            Get
                Return _safeFileName
            End Get
            Set(value As String)
                _safeFileName = value
            End Set
        End Property

        Private _fileInfofile As FileInfo

        Public Property FileInfoFile As FileInfo
            Get
                Return _fileInfofile
            End Get
            Set(value As FileInfo)
                _fileInfofile = value
            End Set
        End Property


        Private Sub OKButton_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)
            Me.DialogResult = True
        End Sub

        Private Sub CancelButton_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)
            Me.DialogResult = False
        End Sub

        Private Sub BrowseButton_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)
            Dim openFileDialog As OpenFileDialog = New OpenFileDialog
            If (openFileDialog.ShowDialog = True) Then
                Me.FileTextBox.Text = openFileDialog.File.Name
                Me.SafeFileName = openFileDialog.File.Name
                Me.FileTextBox.IsReadOnly = True
                Dim myFileInfo As FileInfo = openFileDialog.File
                Me.FileInfoFile = myFileInfo

            End If
        End Sub
    End Class


End Namespace
